package com.cao.isemulator;

import android.content.Context;
import android.content.pm.FeatureInfo;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;

import java.io.File;


public class MainActivity extends ActionBarActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView text = (TextView)findViewById(R.id.hellotext);
        if(FindEmulator.isEmulator(getApplicationContext())) {
            text.setText("模拟器");
        } else {
            text.setText("非模拟器");
        }
        TextView text1 = (TextView)findViewById(R.id.hellotext1);
        TextView text2 = (TextView)findViewById(R.id.hellotext2);
        TextView text3 = (TextView)findViewById(R.id.hellotext3);
        TextView text4 = (TextView)findViewById(R.id.hellotext4);
        TextView text5 = (TextView)findViewById(R.id.hellotext5);
        TextView text6 = (TextView)findViewById(R.id.hellotext6);
        TextView text7 = (TextView)findViewById(R.id.hellotext7);


        text1.setText("手机厂商: "+android.os.Build.MANUFACTURER);
        text2.setText("型号: "+android.os.Build.MODEL);
        text3.setText("Android系统版本号: "+ android.os.Build.VERSION.RELEASE);

        //手机号
        TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = tm.getDeviceId();       //取出IMEI
        String tel = tm.getLine1Number();     //取出MSISDN，很可能为空
        String serino =tm.getSimSerialNumber();  //取出ICCID
        String imsi =tm.getSubscriberId();     //取出IMSI

        text4.setText("IMEI: "+imei);
        text5.setText("TEL: "+tel);
        text6.setText("SERINO: "+serino);
        text7.setText("IMSI: "+imsi);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
